# rabbitmq 死信队列监听

import pika
import json
import time

config = {
    'exchange': 'cache_exchange',
    'routing_key': 'cache',
    'queue': 'cache_queue',
}

credentials = pika.PlainCredentials('autotest', '123456')
connection = pika.BlockingConnection(pika.ConnectionParameters(
            host = '127.0.0.1', port = '5672', virtual_host = 'autotest', credentials = credentials))
channel = connection.channel()

latest = True

while latest :
    message = channel.basic_get(config['queue'])
    print(message)
    if any(message) == False:
        break

connection.close()